home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacGames Sampler
/
PHT MacGames Bundle.iso
/
MacSource Folder
/
Samples from the CD
/
C and C++
/
CTools ƒ
/
CTools Docs
< prev
next >
Wrap
Text File
|
1989-02-05
|
12KB
|
243 lines
/*----------------------------------------------------------------------------
--
-- Docs for CTOOLS
--
-- A Collection of C Programming File Utilities for the Macintosh
--
-- by G. Haddock
--
------------------------------------------------------------------------------*/
Copyright 1988, 1989 by G. Haddock.
Portions of this program are copyright by Think Technologies.
In the spirit of the public domain source of the original source code for
most of the "C" tools, this program is released for personal, non-commercial
use as a productivity tool.
General:
This program is a collection of C file tools and utilities that are useful
for formatting and reading C source files, particularly some of the stuff
that you obtain from the public domain sources. These tools and utilities
have been wrapped inside a Macintosh(TM) shell that includes a rudimentary
editor function. The editor is not intended for major programming
activities, but it is useful for viewing and making small modifications to
files.
Since the editor uses TextEdit, the files are limited in size to 32K after
tab expansion. (This is about 20 printed pages of source code.) If you
attempt to read a file into the application which is longer, you will receive
an Error message. Of course, you are never supposed to let your C source files
get that long anyway. If you find one longer than that somewhere, you may have
to break it into smaller segments using a different text editor before
processing.
Because TextEdit does not handle tabs, an input filter expands out any tabs
to the appropriate number of spaces upon reading the file, or entering text, and
will re-convert any spaces (which are not inside " or ' quotes) back into tabs
upon saving the file back to disk. This will generally clean up files where
spaces and tabs were originally used interchangeably. The tabs settings in
this version are FIXED at an equal separation of 4 spaces.
In the interests of encouraging the user to not overwrite the original
unprocessed source file until you are sure that you have what you want, the
program will not do a simple "SAVE" command upon closing a file, but will
always force the user back through the "SAVE AS" procedure, which will ask
permission before overwriting any pre-existing files.
Source Formatter:
A "C" Source Formatter or "Pretty Printer" which operates on files. This
utility will operate on any file which ends in the suffix ".c". It will
re-indent a file according to the nesting level of the segments of the program.
Multiple statements per line will be reformatted to have one statement per line.
The logic flow of a program (as viewed by a C compiler) should not be disturbed,
but you will generally find the program much easier to read if it was not
originally indented according to nesting levels.
Modified to run in a Macintosh shell environment from public domain source
obtained from the C Users Group. Numerous changes were made to improve
handling of "if()" statements which are nested without brackets.
Original author credit: W. C. Colley, III and J. W. Kindschi, Jr.
CFLOW:
Abstracts C function calls and declarations from a C source file and
produces a listing of the program's calling hierarchy. This utility will
operate on any file which ends in the suffix ".c". It will generate a new file
with the original file name plus the suffix ".flw" which contains a sequential
indented list of all functions called from each function declaration.
It is a useful utility for understanding the overall flow and calling
structure of a program, particularly one that has insufficient or no
documentation or commenting.
Modified to run in a Macintosh shell environment, plus multiple minor bugs
fixed, from public domain source obtained from the C Users Group.
Original author credit: W. C. Colley, III and Mark Ellington.
CCHECK:
A program to find and report all badly matched openers and closers plus
assignment/equality confusions in a C source file. This utility will operate
on any file which ends in the suffix ".c". It will generate a new file with
the original file name plus the suffix ".check" which contains the output
comments from the utility. It specifically comments on unbalanced openings
and closings of brackets, braces, etc., and specifically looks for the use
of "=" rather than "==" inside decision statements. If the "Verbose" option is
selected, the utility will comment on the placement of opening and closing
braces which are not vertically aligned in the source code.
Modified to run in a Macintosh shell environment from public domain source
dated March 1987. Original author credit: Steve Draper, expanding on "cnest"
by Tom Anderson.
Cross Reference:
This is a concordance or cross-reference utility for 'C' programs. This
utility will operate on any file which ends in the suffix ".c". It will
generate a new file with the original file name plus the suffix ".xref" which
contains the cross referenced output from the utility. It will generate a list
of all variable and function names in the source code, along with the line
number in which they appear. In accordance with the operation of
Think/Lightspeed C (TM), this program does not recognise nested comments, but it
will properly deal with comments or quoted items which are inside single
or double quotes.
Options support the following features:
- Cross-referencing of Think/Lightspeed C reserved words.
- Generation of line numbered listing only.
- Generation of cross-reference only.
If the file is large, that is, over 20K bytes, and swells in size when you try
to save both the line numbered listing and cross reference listing inside
the same .xref file such that it swells beyond 32K, you may have to break up
the file or save the numbered listing and cross-reference listing in separate
files. If you have a programmer's editor like QUED (TM), then you really won't
need the numbered listing anyway.
Modified to run in a Macintosh shell environment from public domain source
provided by the C Users Group. Keywords, reserved words, and comment
processing were aligned with Think/Lightspeed C usage. The program will now
only deal with a single level of comments, not comments nested within comments.
Original author credit: Phillip N. Hisley, W. H. Rauser, W. C. Colley, III.
Strip File:
This tool is useful for cleaning up and converting files that you have
imported from other sources such as IBM-PC based files, or Unix systems.
Text files obtained from IBM-PC based sources as viewed on a Macintosh
usually have a row of "boxes" down the left edge of the screen, and a
horizontal row of boxes at the bottom of the file. These are actually control
characters which are present in the file, but are not used by the Macintosh.
To convert and clean up this kind of file, just click "OK" at the Stripper
dialog, which will remove all control characters not recognized by the
Macintosh, as well as any characters with values above $7F.
If the file does not appear to have any carriage returns, and the file just
wraps around and around with little "boxes" where you think the start of each
line should be, then the file is probably a Unix type file, and the additional
"Convert Unix File" option should also be checked. Unix type text files use
"LineFeed" ($0A) rather than "CarriageReturn" ($0D) as the Mac does to mark
a new line. The "Convert Unix File" option will substitute a CarriageReturn
for each LineFeed before stripping. If you check this box on an IBM-PC type
file, then you will end up with everything double spaced, but no other harm done.
Although most Macintosh programs will not recognise them, there are some
text editors like QUED which will respond to imbedded "Form Feeds" for
page break control. If these exist in the program, and you want to save
them, activate the "Save FormFeed" option.
Pascal to C:
This utility will translate Pascal keywords and operators to their
C equivalent. This utility will operate on any file which DOES NOT end in the
suffix ".c". It will generate a new file with the original file name plus
the suffix ".P2.c" which contains the translated output from the utility.
This program is an aid in translating a Pascal program to C. It will do
much of the repetitive mechanical conversion. HOWEVER, the programmer will
need a working knowledge of both Pascal and C to manually convert some Pascal
features which this program can not handle, or for which there is no direct
C equivalent.
MASSAGING OF THE OUTPUT BY A PROGRAMMER WILL BE NEEDED.
The output will generally not be legal C code. This program provides a
simple mechanical translation of those Pascal keywords and structures that have
a direct equivalent in "C". Structures such as "WITH" in Pascal which have no
direct equivalent in C will have to be manually re-coded. In particular,
beware of the differences between Pascal and C in the way that the languages
pass variables as parameters to procedures. Pascal passes a pointer to a
variable, such that operations inside a procedure will change the original
variable. In C, a copy of the parameter is passed, (even when the name is the
same), and any operations on the parameter only occur on the copy, and not the
original, so that there can be significant differences in the logic of a
program, even if they appear "identical" in both Pascal and "C". If you are
translating a Pascal program into "C", this utility will save you significant
time by doing the majority of the translation for you.
The Pascal source can be in upper, lower, or mixed case. Case is preserved
during translation. Structures translated properly include simple assignment
and comparison statments, variable, type, and label declarations, enumerated
types, and procedure and function declarations and instances.
Structures NOT always completely translated properly include sets,
constant declarations, variant records, files, subrange types, VAR parameters,
CASE, FOR, UNTIL, WITH, READ, and WRITE statements, and nested procedures.
The translator will generally provides hints or warnings about untranslatable
regions by inserting UPPERCASE messages enclosed with /* and */ into the
translated source. Error messages are of the form /***# Expected ... ***/.
Error recovery is poor- the first error in translation may result in a
very long stream of error messages. If a particular area of the Pascal
program is creating errors, it may be prudent to just comment it out, and
translate it manually after the program translates the rest of the file.
The translated source can be cleaned up considerably by running it
through the "Source Formatter" after translation.
Public domain source modified to run in a Macintosh shell environment with
keyword translation aligned with Think/Lightspeed C reserved words.
This program was reportedly inspired by a program in February 1985 Byte
Magazine which did a C TO PASCAL conversion.
Original author credit for this version's source: James A. Mullens and
Dan Kegel.
Prototype Generator:
This utility will generate C type prototypes from a C source file.
This utility will operate on any file which ends in the suffix ".c". It will
generate a new file with the original file name plus the suffix ".pr" which
contains the list of prototypes output by the utility.
Any correspondence may be directed to Graham Haddock on
GEnie: G.HADDOCK
CompuServe: 70611,1530
G. Haddock February 4, 1989.